home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / TextPainter.h < prev    next >
C/C++ Source or Header  |  1992-08-26  |  3KB  |  78 lines

  1. #ifndef TextLinePainter_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define TextLinePainter_First
  7.  
  8. #include "Object.h"
  9. #include "TextStyles.h"
  10. #include "Text.h"
  11.  
  12. //---- class TextPainter ------------------------------------------------
  13. //     paint text lines
  14.  
  15. class TextPainter: public Object {    
  16. public:
  17.     MetaDef(TextPainter);
  18.     TextPainter();
  19.     ~TextPainter();
  20.     
  21.     int LineWidth(Text *t, int from, int to);
  22.     void LineHeight(Text *t, LineDesc &ld, int start, int end);
  23.     
  24.     virtual void Draw(Text *t, Point p, int from, int to, 
  25.            Rectangle lr, Rectangle clip, bool invis= TRUE);
  26.     virtual int Map(Text *t, int from, int to, int stop, int x, 
  27.            int width, int *posX); 
  28.     int GetFormatWidth(Text *t, int at, int width);
  29.     int Tabulate(Text *t, int x, int at, int linestart);
  30.  
  31. private:
  32.     byte *linebuf;
  33.     byte *line;
  34.     ParaStyle *ps;          // current paragraph style on a line
  35.     CharStyle *sp;          // current character style on a line
  36.     int graphicChar;        // graphic escape character
  37.     int nextFontChange;     // position of next font change on line
  38.     
  39.     bool TestFontChange(Text *t, int at, CharStyle *&sp);
  40.     bool TestVisualMark(Text *t, int at, int ch);
  41.     
  42.     void Init(Text *t, int from, int to);
  43.     int Strip(Text *t, int from, int to);
  44.     int CalcSpace(Text *t, int w, int from, int to, int &space, int &blanks, int &ntab);
  45.     int CalcIndent(Text *t, ParaStyle *p, int at, int &width);
  46.     int CalcWidth(Text *t, int from, int to);
  47.     int CalcTabWidth(Text *t, ParaStyle *p, int x, int at);
  48.     int TabColWidth(Text *t, int start, char *stops);
  49.     void SetCharStyle(CharStyle *cs);
  50.     bool IsJustified(Text *t, int at);
  51.     int FirstCharPos(Text *t, int width, int start, int end);
  52.     
  53.     void ShowInvisible(byte ch);
  54.     void ShowNoBreak(Point p, Rectangle clip, Text *t, int start, int end);
  55.     void ShowKeepNext(Point p, Rectangle clip, Text *t, int start, int end);
  56.     void DrawVisualMark(Point p, class VisualMark *vmp, Rectangle clip, Rectangle line, bool border);
  57. };
  58.  
  59. //---- inlines --------------------------------------------------------------
  60.  
  61. inline bool TextPainter::TestFontChange (Text *t, int at, CharStyle *&sp)
  62.     if (at == nextFontChange) {
  63.     nextFontChange= t->GetNextFontChange(at, sp);
  64.     return TRUE;
  65.     }
  66.     else 
  67.     return FALSE;
  68. }
  69.  
  70. inline bool TextPainter::TestVisualMark(Text *t, int at, int ch)
  71.     return (graphicChar && ch == graphicChar && t->IsVisualMark(at)); 
  72. }
  73.  
  74. #endif
  75.  
  76.